var Adv_skd=require("./Adv_skd")
var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("AssetsMap"),
    c = e("BundleNames"),
    l = e("Util"),
    d = e("ConfigGameData"),
    u = e("GameData"),
    p = e("ProgressTaskData"),
    h = e("SkinLevelData"),
    f = e("SkinLevelViewSnake"),
    _ = e("SkinTrialViewItemData"),
    y = cc._decorator,
    m = null,
    g = y.ccclass,
    v =
        (y.property,
        (function (e) {
            function t() {
                var t = (null !== e && e.apply(this, arguments)) || this;
                return (
                    (t.content = null),
                    (t.btn_play = null),
                    (t.items = null),
                    (t.positions = []),
                    (t.hw_banner = null),
                    t
                );
            }
            return (
                a(t, e),
                (t.prototype.onLoad = function () {
                    this.isCache = !1;
                }),
                (t.prototype.onResetView = function () {
                    var t = this;
                    e.prototype.onResetView.call(this),
                        game.UIManager.instance.showLoadResView([c.default.Game], [c.default.Game], function () {
                            t.init(), t.__addEvent();
                        }),
                        ad.curr_platform === window.ad.Platform.VIVO && ad.adInterface.hideGamePortal(!1);

                        Adv_skd.default.instance.hideAllAdv();
                        Adv_skd.default.instance.showGridAdRight();
                        Adv_skd.default.instance.showGridAdLeft();
                        Adv_skd.default.instance.showBannerAd();
                }),
                (t.prototype.registerMediator = function () {
                    e.prototype.registerMediator.call(this);
                }),
                (t.prototype.removeMediator = function () {
                    e.prototype.removeMediator.call(this);
                }),
                (t.prototype.start = function () {}),
                (t.prototype.onDisable = function () {
                    Adv_skd.default.instance.hideAllAdv();

                    cc.SDK.hideBanner(), this.unscheduleAllCallbacks(), (m = null);
                }),
                (t.prototype.onEnable = function () {
                    cc.SDK.showBanner();
                }),
                (t.prototype.showCallBack = function (e) {
                    (m = e), console.log("设置 回调函数", m);
                }),
                (t.prototype.__addEvent = function () {
                    e.prototype.addEvent.call(this),
                        this.btn_play.on(game.EngineEventType.NodeEvent.click, this.onClick_btn_play, this),
                        this.node.on("btn_play", this.onClick_btn_play, this);
                }),
                (t.prototype.removeEvent = function () {
                    e.prototype.removeEvent.call(this),
                        this.btn_play.off(game.EngineEventType.NodeEvent.click, this.onClick_btn_play, this),
                        this.node.off("btn_play", this.onClick_btn_play, this);
                }),
                (t.prototype.init = function () {
                    var e = this;
                    (this.isCache = !1),
                        (this.content = this.node.getChildByName("content")),
                        (this.btn_play = this.content.getChildByName("btn_play")),
                        (this.items = this.content.getChildByName("items"));
                    var t = this.items.children;
                    t.forEach(function (t) {
                        return e.positions.push(t.position.clone());
                    });
                    for (var o = 0; o < t.length; o++) (r = t[o]).x = this.positions[1].clone().x;
                    this.playMove(0);
                    var n = h.SkinLevelData.instance.skinList,
                        i = [];
                    for (o = 0; o < n.length; o++) {
                        var a = n[o];
                        a.SkinType != h.SkinType.none && i.push(a.chinese);
                    }
                    for (o = 0; o < t.length; o++) {
                        var r = t[o],
                            s = l.default.randomFrom(0, i.length - 1);
                        (r.getComponent(_.default).skinChineseName = i[s]),
                            i.splice(s, 1),
                            r.getComponent(_.default).init();
                    }
                    var c = p.default.instance.taskListScore,
                        d = p.default.instance.getTaskProgressIndex(),
                        u = this.node.getChildByName("content").getChildByName("progressTaskTip");
                    if (d == c.length) u.active = !1;
                    else {
                        var f = p.default.instance.getScore(),
                            y = c[d] - f,
                            m = p.default.instance.taskListName[d];
                        (u.getChildByName("label1").getComponent(cc.RichText).string =
                            "<color=#FFFFFF>再赢</color><color=#A4DA26>" +
                            y +
                            "</c><color=#FFFFFF>长度即可</color><color=#FFFFFF>获得</color><color=#A4DA26>" +
                            m +
                            "</c>"),
                            u
                                .getChildByName("label1")
                                .runAction(
                                    cc.repeatForever(
                                        cc.sequence(
                                            cc.place(u.width / 2, 0),
                                            cc.moveTo(1.5, cc.v2(-u.width / 2, 0)),
                                            cc.delayTime(2),
                                            cc.moveTo(1.5, cc.v2(-(u.width / 2 + u.getChildByName("label1").width), 0))
                                        )
                                    )
                                );
                    }
                }),
                (t.prototype.onClick_btn_play = function () {
                    m && "function" == typeof m
                        ? (m(), game.AudioManager.playBtnEffect(), (this.node.active = !1))
                        : (console.log("没有回调函数"),
                          this.record(),
                          game.AudioManager.playBtnEffect(),
                          d.default.instance.ResetData(),
                          (this.node.active = !1),
                          game.PopupManager.instance.showPopView(s.default.PopupMap.MatchPlayersView, null, !1, !0));
                }),
                (t.prototype.record = function () {
                    var e = ad.curr_platform === window.ad.Platform.TOU_TIAO;
                    u.default.instance.GameModel === u.GameModel.endless &&
                        (game.log("T=> 无尽模式立即开始"),
                        e && window.tt.reportAnalytics("Moshi_WuJin_LiJiKaishi", {}));
                }),
                (t.prototype.playMove = function (e) {
                    var t = this;
                    this.items.children[e].runAction(cc.moveTo(0.3, cc.v2(this.positions[e]))),
                        e >= 2
                            ? this.scheduleOnce(function () {
                                  t.playFlipX(0);
                              }, 0.3)
                            : this.scheduleOnce(function () {
                                  t.playMove(e + 1);
                              }, 0.3);
                }),
                (t.prototype.playFlipX = function (e) {
                    var t = this;
                    this.items.children[e].runAction(
                        cc.sequence(
                            cc.scaleTo(0.2, 0, 1),
                            cc.callFunc(function () {
                                (t.items.children[e].getChildByName("mask").active = !1), t.showSnake(e);
                            }),
                            cc.scaleTo(0.2, 1, 1),
                            cc.callFunc(function () {
                                t.items.children[e]
                                    .getChildByName("btn_click_ani")
                                    .runAction(
                                        cc.repeatForever(cc.sequence(cc.scaleTo(0.7, 1.1), cc.scaleTo(0.7, 0.9)))
                                    );
                            })
                        )
                    ),
                        e >= 2 ||
                            this.scheduleOnce(function () {
                                t.playFlipX(e + 1);
                            }, 0.4);
                }),
                (t.prototype.showSnake = function (e) {
                    var t = this.content
                            .getChildByName("SkinLevelViewSnake" + e)
                            .getChildByName("snake")
                            .getComponent(f.default),
                        o = this.items.children[e].getComponent(_.default).data;
                    t.init(1.5, 10), t.refreshView(o, 5);
                }),
                (t.prototype.onAddToScene = function () {
                    e.prototype.onAddToScene.call(this);
                }),
                (t.prototype.onRemoveToScene = function () {
                    e.prototype.onRemoveToScene.call(this);
                }),
                r([g], t)
            );
        })(game.BasePopView));
i.default = v;
